﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ProjScan.RecordManager.AssetData;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine.Video;

namespace ProjScan.RecordManager
{
	// Token: 0x02000290 RID: 656
	internal class VideoClipRecordManager : RecordManagerBase<VideoClipAssetData>
	{
		// Token: 0x0600113F RID: 4415 RVA: 0x000514F4 File Offset: 0x0004F6F4
		public override void PrepareAssets()
		{
			this.datas = new List<VideoClipAssetData>();
			string[] array = new string[]
			{
				"mov",
				"avi",
				"mpg",
				"mp4",
				"mpeg",
				"asf"
			};
			int num = AssetPathManager.Instance.artPathList.Length;
			for (int i = 0; i < num; i++)
			{
				bool isEditor = Singleton<ScanInfo>.Instance.isEditor;
				if (isEditor)
				{
					EditorUtility.DisplayProgressBar("Proj Scan [" + this.TableTag + "]", string.Concat(new string[]
					{
						"Preparing ",
						this.TableTag,
						"(",
						this.datas.Count.ToString(),
						")..."
					}), (float)i * 1f / (float)num);
				}
				string text = AssetPathManager.Instance.artPathList[i];
				string text2 = Path.GetExtension(text).ToLower().Replace(".", "");
				bool flag = Enumerable.Contains<string>(array, text2);
				if (flag)
				{
					this.ActiveAllRecord();
					bool flag2 = this.CheckAssetPathRules(text);
					if (flag2)
					{
						VideoClipImporter videoClipImporter = AssetImporter.GetAtPath(text) as VideoClipImporter;
						bool flag3 = videoClipImporter != null;
						if (flag3)
						{
							VideoClip videoClip = AssetDatabase.LoadAssetAtPath(text, typeof(VideoClip)) as VideoClip;
							bool flag4 = videoClip != null;
							if (flag4)
							{
								VideoClipAssetData videoClipAssetData = new VideoClipAssetData(AssetPathManager.Instance.GetID(Path.GetDirectoryName(text)), text, videoClip, videoClipImporter);
								videoClipAssetData.id = this.datas.Count;
								this.ValidateAsset(videoClipAssetData);
								videoClipAssetData.Reset();
								this.datas.Add(videoClipAssetData);
								bool flag5 = this.datas.Count % 100 == 0;
								if (flag5)
								{
									ToolsHelper.GC();
								}
							}
						}
					}
				}
			}
		}

		// Token: 0x1700038B RID: 907
		// (get) Token: 0x06001140 RID: 4416 RVA: 0x000516F0 File Offset: 0x0004F8F0
		public override string TableTag
		{
			get
			{
				return "videoclip";
			}
		}
	}
}
